//
//  TKYAddCenterView.m
//  StationHouseHelper
//
//  Created by apple on 2018/5/4.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYAddCenterView.h"
#import "TKYCustomButton.h"
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#define Margin  10
@interface TKYAddCenterView()
//进度
@property (nonatomic, strong)TKYCustomButton *progressBtn;
//质量
@property (nonatomic, strong)TKYCustomButton *qualityBtn;
//安全
@property (nonatomic, strong)TKYCustomButton *safetysBtn;

@property (nonatomic, strong)UIButton *closeBtn;

@property (nonatomic, strong)UIView *closeView;



@end
@implementation TKYAddCenterView
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.9];
        [self addSubview:self.progressBtn];
        [self addSubview:self.qualityBtn];
        [self addSubview:self.safetysBtn];
        [self addSubview:self.closeView];
        [self.closeView addSubview:self.closeBtn];
        
        self.backgroundColor = [UIColor colorWithWhite:0.95 alpha:0.95];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgViewEvent)];
        [self addGestureRecognizer:tap];
    }
    return self;
}

- (void)tapBgViewEvent {
    if (self.touchBgView) {
        self.touchBgView();
    }
}

- (TKYCustomButton *)progressBtn{
    if (_progressBtn == nil) {
        _progressBtn = [[TKYCustomButton alloc]initWithFrame:CGRectMake((kScreenWidth - kWidthScale*75*3)/4*3+kWidthScale *75*2, kScreenHeight -228, kWidthScale *75, kWidthScale*75 +kHeightScale *20)];
        _progressBtn.imageRect = CGRectMake(0, 0, kWidthScale *75, kWidthScale*75 );
        _progressBtn.titleRect = CGRectMake(10, kHeightScale *85, kWidthScale *75, 20);
        _progressBtn.titleLabel.font=[UIFont systemFontOfSize:14.0];
        [_progressBtn setImage:[UIImage imageNamed:@"progress_report"] forState:UIControlStateNormal];
        [_progressBtn setTitle:@"进度填报" forState:UIControlStateNormal];
        [_progressBtn setTitleColor:kRGBColor(100, 100, 100, 1) forState:UIControlStateNormal];
        [_progressBtn addTarget:self action:@selector(progressBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _progressBtn;
}

- (TKYCustomButton *)qualityBtn{
    if (_qualityBtn == nil) {
        _qualityBtn = [[TKYCustomButton alloc]initWithFrame:CGRectMake((kScreenWidth - kWidthScale*75*3)/4*2 +kWidthScale *75, kScreenHeight -228, kWidthScale *75, kWidthScale*75 +kHeightScale *20)];
        _qualityBtn.imageRect = CGRectMake(0, 0, kWidthScale *75, kWidthScale*75 );
        _qualityBtn.titleRect = CGRectMake(10, kHeightScale *85, kWidthScale *75, 20);
        _qualityBtn.titleLabel.font=[UIFont systemFontOfSize:14.0];
        [_qualityBtn setImage:[UIImage imageNamed:@"quality_problem"] forState:UIControlStateNormal];
        [_qualityBtn setTitle:@"质量问题" forState:UIControlStateNormal];
        [_qualityBtn setTitleColor:kRGBColor(100, 100, 100, 1) forState:UIControlStateNormal];
        [_qualityBtn addTarget:self action:@selector(qualityBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _qualityBtn;
}

- (TKYCustomButton *)safetysBtn{
    if (_safetysBtn == nil) {
        _safetysBtn = [TKYCustomButton buttonWithType:UIButtonTypeCustom];
        _safetysBtn.frame =  CGRectMake((kScreenWidth - kWidthScale*75*3)/4, kScreenHeight -228, kWidthScale *75, kWidthScale*75 +kHeightScale*20);
        _safetysBtn.imageRect = CGRectMake(0, 0, kWidthScale *75, kWidthScale*75 );
        _safetysBtn.titleRect = CGRectMake(10, kHeightScale *85, kWidthScale *75, 20);
        _safetysBtn.titleLabel.font=[UIFont systemFontOfSize:14.0];
        [_safetysBtn setImage:[UIImage imageNamed:@"safety_problem"] forState:UIControlStateNormal];
        [_safetysBtn setTitle:@"安全问题" forState:UIControlStateNormal];
        [_safetysBtn setTitleColor:kRGBColor(100, 100, 100, 1) forState:UIControlStateNormal];
        [_safetysBtn addTarget:self action:@selector(safetysBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _safetysBtn;
}

- (UIView *)closeView{
    if (_closeView == nil) {
        _closeView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenHeight-kHeightScale *48, kScreenWidth, kHeightScale *48)];
        UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.5)];
        line.backgroundColor = kUIColorFromRGB(0XE5E5E5, 1);
        [_closeView addSubview:line];
        //_closeView.backgroundColor = [UIColor yellowColor];
    }
    return _closeView;
}

- (UIButton *)closeBtn{
    if (_closeBtn == nil) {
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _closeBtn.frame = CGRectMake(kScreenWidth/2 -35/2, kHeightScale *6, kWidthScale *35, kHeightScale *35);
        [_closeBtn setImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
        [_closeBtn addTarget:self action:@selector(closeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeBtn;
}

- (void)closeBtnClick:(UIButton *)button{
    if (self.closeBtnBlock) {
        self.closeBtnBlock(button);
    }
}

- (void)safetysBtnClick:(UIButton *)button{
    if (self.safetysBtnBlock) {
        self.safetysBtnBlock(button);
    }
}

- (void)qualityBtnClick:(UIButton *)button{
    if (self.qualityBtnBlock) {
        self.qualityBtnBlock(button);
    }
}

- (void)progressBtnClick:(UIButton *)button{
    if (self.progressBtnBlock) {
        self.progressBtnBlock(button);
    }
}
@end
